<div class="tl_loader">
    <img src="<?php echo $this->urlbase.'/public/media/images/loader.gif';?>" />
</div>

<div class="tl_descanco"></div>


<div class="tl_aplicacao">
    <div class="topo">
        <span class="btn_menu"></span>
        <a href="<?php echo $this->urlbase;?>">
            <span class="logo_topo"></span>
        </a>
    </div>
    <div class="lf_menu">
        <ul>
            <?php 
            foreach($this->result as $row){
                $img = glob('public/upload/pagina/'.$row['PAG_ID'].'_men.*');
                if(isset($img[0]))$img = $img[0];
                else $img = '';
            ?>
            <li style="background-color: <?php echo $row['PAG_CORBAC']; ?>">
                <a href="<?php echo $this->urlbase.'/index/pagina/id/'.$row['PAG_ID'];?>">
                    <img src="<?php echo $this->urlbase.'/'.$img;?>" />
                    <?php echo $row['PAG_NOM']; ?>
                    <?php if($this->id == $row['PAG_ID']){ ?>
                    <div class="st_cima" style="border-left-color: <?php echo $row['PAG_CORBAC']; ?>"></div>
                    <?php } ?>
                </a>
            </li>
           <?php } ?>
        </ul>
    </div>
    
    <div class="rg_cnt">
        
    <?php if($this->row['PAG_TIP'] == 1) { ?>
    
        <?php
            $img = glob('public/upload/pagina/'.$this->row['PAG_ID'].'_til.*');
            if(isset($img[0]))$img = $img[0];
            else $img = '';


            $img_tpp = glob('public/upload/pagina/'.$this->row['PAG_ID'].'_tpp.*');
            if(isset($img_tpp[0]))$img_tpp = $img_tpp[0];
            else $img_tpp = '';



            $where = 'VID_ID > 0 AND VID_STA = 1 ';
            $where .= ' AND VID_MOD LIKE "pagina"';
            $where .= ' AND VID_MODNUM = '.$this->row['PAG_ID'];

            $query = 'SELECT SQL_CACHE * FROM VIDEO WHERE '.$where.' ORDER BY VID_ORD ASC';
            $r_video = $this->db->fetchAll($query);


        ?>
        
        <div class="cnt_img">
            <?php 
                $img_tes = glob('public/upload/pagina/'.$this->row['PAG_ID'].'_g_*.*');
            if(isset($img_tes[0]) || count($r_video) > 0){ ?>
            <span class="toque"></span>
            <?php } ?>
            <img class="img_topo" src="<?php echo $this->urlbase.'/'.$img_tpp;?>" />
            <div class="img_galeria">

        <?php foreach($r_video as $rvid) { ?>
            <a href="<?php echo $rvid['VID_LNK'];?>" class="swipebox" title="<?php echo $rvid['VID_NOM']; ?>"></a>
        <?php } ?>

        <?php

            $where = 'GAL_ID > 0';
            $where .= ' AND GAL_MOD LIKE "pagina"';
            $where .= ' AND GAL_MODNUM = '.$this->row['PAG_ID'];

            $query = 'SELECT SQL_CACHE * FROM GALERIA WHERE '.$where.' ORDER BY GAL_ORD ASC';
            $result = $this->db->fetchAll($query);
            foreach($result as $rimg) {

                $img_top = '';
                $img_arr = glob('public/upload/pagina/'.$rimg['GAL_IDIMG']);
                foreach($img_arr as $src) $img_top = $src;

                if(strlen($img_top) > 1){
        ?>
            <a href="<?php echo $this->urlbase.'/'.str_replace('_tb', '', $img_top);?>" class="swipebox" title="<?php echo $this->row['PAG_NOM']; ?>">
                <img src="<?php echo $this->urlbase.'/'.$img_top;?>" />
            </a>
        <?php       } 
            }
        ?>
            </div>
        </div>
        <div class="cnt_texto">
            <div class="ttl_img">
                <span class="content_bord" style="background-color: <?php echo $this->row['PAG_CORBAC']; ?>">
                    <img src="<?php echo $this->urlbase.'/'.$img;?>" />
                </span>
            </div>
            <div class="ttl_txt">
                <div class="tll" style="color: <?php echo $this->row['PAG_CORBAC']; ?>">
                    <?php echo $this->row['PAG_NOM']; ?>
                </div>

                <p>
                    <?php echo $this->row['PAG_TXT']; ?>
                </p>

                <div class="bl_it_menu" >
                    <?php 
                        $prox  = 0;
                        $link_prox  = '';
                        foreach($this->result as $row){
                            $style = '';

                            if($prox == 1 && strlen($link_prox) == 0){
                                $link_prox = $this->urlbase.'/index/pagina/id/'.$row['PAG_ID'];
                            }

                            if($this->id == $row['PAG_ID']){
                                $style = 'style="background-color: '.$this->row['PAG_CORBAC'].'"';
                                $prox = 1;
                            }


                    ?>
                        <a href="<?php echo $this->urlbase.'/index/pagina/id/'.$row['PAG_ID'];?>" <?php echo $style; ?>></a>
                    <?php } ?>
                </div>
                <?php if(strlen($link_prox) > 5){?>
                    <a href="<?php echo $link_prox;?>">
                        <div class="st_avan"></div>
                    </a>
                <?php } ?>
            </div>
        </div>
        
    <?php } else if($this->row['PAG_TIP'] == 2) { ?>
        
        <div class="cnt_subpag">
            <ul>
            <?php 
            
            $query = 'SELECT SQL_CACHE * FROM SUBPAGINA WHERE PAG_ID = '.$this->row['PAG_ID'].' AND SPG_STA = 1 ORDER BY SPG_ORD';
            $subpag = $this->db->fetchAll($query);
            foreach($subpag as $row){
                $img = glob('public/upload/subpagina/'.$row['SPG_ID'].'.*');
                if(isset($img[0]))$img = $img[0];
                else $img = '';
            ?>
                <li style="background-color: <?php echo $row['SPG_CORBAC']; ?>">
                    <div class="sub_cnt_img">
                        <img src="<?php echo $this->urlbase.'/'.$img;?>" />
                        <div class="ttl"><?php echo $row['SPG_NOM']; ?></div>
                        <div class="stl"><?php echo $row['SPG_NOMSUB']; ?></div>
                        <div class="txt"><?php echo $row['SPG_TXT']; ?></div>
                    </div>
                </li>
            <?php } ?>
            </ul>
            
            <div class="bl_it_menu" >
                    <?php 
                        $prox  = 0;
                        $link_prox  = '';
                        foreach($this->result as $row){
                            $style = '';

                            if($prox == 1 && strlen($link_prox) == 0){
                                $link_prox = $this->urlbase.'/index/pagina/id/'.$row['PAG_ID'];
                            }

                            if($this->id == $row['PAG_ID']){
                                $style = 'style="background-color: '.$this->row['PAG_CORBAC'].'"';
                                $prox = 1;
                            }


                    ?>
                        <a href="<?php echo $this->urlbase.'/index/pagina/id/'.$row['PAG_ID'];?>" <?php echo $style; ?>></a>
                    <?php } ?>
                </div>
                <?php if(strlen($link_prox) > 5){?>
                    <a href="<?php echo $link_prox;?>">
                        <div class="st_avan"></div>
                    </a>
                <?php } ?>
            
        </div>
        
    <?php } else if($this->row['PAG_TIP'] == 3) { ?>
        
        <?php
            $img = glob('public/upload/pagina/'.$this->row['PAG_ID'].'_til.*');
            if(isset($img[0]))$img = $img[0];
            else $img = '';


            $img_tpp = glob('public/upload/pagina/'.$this->row['PAG_ID'].'_tpp.*');
            if(isset($img_tpp[0]))$img_tpp = $img_tpp[0];
            else $img_tpp = '';

        ?>
        
        <div class="cnt_img">
            <?php 
                $img_tes = glob('public/upload/pagina/'.$this->row['PAG_ID'].'_g_*.*');
            if(isset($img_tes[0]) || count($r_video) > 0){ ?>
            <span class="toque"></span>
            <?php } ?>
            <img class="img_topo" src="<?php echo $this->urlbase.'/'.$img_tpp;?>" />
            <div class="img_galeria">

        <?php foreach($r_video as $rvid) { ?>
            <a href="<?php echo $rvid['VID_LNK'];?>" class="swipebox" title="<?php echo $rvid['VID_NOM']; ?>"></a>
        <?php } ?>

        <?php

            $where = 'GAL_ID > 0';
            $where .= ' AND GAL_MOD LIKE "pagina"';
            $where .= ' AND GAL_MODNUM = '.$this->row['PAG_ID'];

            $query = 'SELECT SQL_CACHE * FROM GALERIA WHERE '.$where.' ORDER BY GAL_ORD ASC';
            $result = $this->db->fetchAll($query);
            foreach($result as $rimg) {

                $img_top = '';
                $img_arr = glob('public/upload/pagina/'.$rimg['GAL_IDIMG']);
                foreach($img_arr as $src) $img_top = $src;

                if(strlen($img_top) > 1){
        ?>
            <a href="<?php echo $this->urlbase.'/'.str_replace('_tb', '', $img_top);?>" class="swipebox" title="<?php echo $this->row['PAG_NOM']; ?>">
                <img src="<?php echo $this->urlbase.'/'.$img_top;?>" />
            </a>
        <?php       } 
            }
        ?>
            </div>
        </div>
        <div class="cnt_texto">
            <div class="ttl_img">
                <span class="content_bord" style="background-color: <?php echo $this->row['PAG_CORBAC']; ?>">
                    <img src="<?php echo $this->urlbase.'/'.$img;?>" />
                </span>
            </div>
            <div class="ttl_txt">
                <div class="tll" style="color: <?php echo $this->row['PAG_CORBAC']; ?>">
                    <?php echo $this->row['PAG_NOM']; ?>
                </div>
                
                <form id="formulario" action="post">
                    <input type="text" placeholder="Nome" name="name" value="" class="capt" required="">
                    <input type="text" placeholder="Telefone" name="telefone" value="" class="telefone" required="">
                    <input type="email" placeholder="E-mail" name="email" value="" class="email" >
                    <input type="text" placeholder="Cidade" name="cidade" value="" class="capt" required="">
                    <input type="submit" name="submit" value="Enviar" >
                </form>
                
            </div>
        </div>
        
        <div class="bl_it_menu" >
            <?php 
                $prox  = 0;
                $link_prox  = '';
                foreach($this->result as $row){
                    $style = '';

                    if($prox == 1 && strlen($link_prox) == 0){
                        $link_prox = $this->urlbase.'/index/pagina/id/'.$row['PAG_ID'];
                    }

                    if($this->id == $row['PAG_ID']){
                        $style = 'style="background-color: '.$this->row['PAG_CORBAC'].'"';
                        $prox = 1;
                    }


            ?>
                <a href="<?php echo $this->urlbase.'/index/pagina/id/'.$row['PAG_ID'];?>" <?php echo $style; ?>></a>
            <?php } ?>
        </div>
        <?php if(strlen($link_prox) > 5){?>
            <a href="<?php echo $link_prox;?>">
                <div class="st_avan"></div>
            </a>
        <?php } ?>
        
    <?php } ?>
        
    </div>
</div>